package com.cci.kangdao.controller;

import com.cci.kangdao.service.ECJVServiceBookService;
import com.cci.kangdao.utilTool.ParameterTool;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author linjiankun
 * @date 2022/11/04 10:40
 */

@Controller
public class ECJVServiceBookController {

    private Logger log = Logger.getLogger(this.getClass().getName());

    @Autowired
    private ECJVServiceBookService ecjvServiceBookService;



    /**
     * 根据机型和服务手册类型获取ECJV服务手册目录列表
     * @param
     * @return
     */
    @RequestMapping("/getECJVServiceBookCatalogue.aspx")
    public ModelAndView getECJVServiceBookCatalogue(HttpServletRequest request,
                                          HttpServletResponse response) throws Exception {

        try{
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("request", request);
            map.put("response", response);
            return ecjvServiceBookService.getECJVServiceBookCatalogue(map);
        }catch(Exception ex){
            log.error(ex.getMessage(),ex);

            String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
            ParameterTool.writeResponse(response, msg);
        }
        return null;
    }




    /**
     * 根据机型,服务手册类型和目录主键id获取服务手册文件
     * @param
     * @return
     */
    @RequestMapping("/getECJVServiceBookList.aspx")
    public ModelAndView getECJVServiceBookList(HttpServletRequest request,
                                                    HttpServletResponse response) throws Exception {

        try{
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("request", request);
            map.put("response", response);
            return ecjvServiceBookService.getECJVServiceBookList(map);
        }catch(Exception ex){
            log.error(ex.getMessage(),ex);

            String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
            ParameterTool.writeResponse(response, msg);
        }
        return null;
    }




    /**
     * ecjv更新服务手册阅读次数接口
     * @param
     * @return
     */
    @RequestMapping("/ecjvUploadHandTolNum.aspx")
    public ModelAndView ecjvUploadHandTolNum(HttpServletRequest request,
                                               HttpServletResponse response) throws Exception {

        try{
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("request", request);
            map.put("response", response);
            return ecjvServiceBookService.ecjvUploadHandTolNum(map);
        }catch(Exception ex){
            log.error(ex.getMessage(),ex);

            String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
            ParameterTool.writeResponse(response, msg);
        }
        return null;
    }
}
